<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>
	<p:layoutUnit id="top" position="north" size="15%">
		<p:toolbar>
			<p:toolbarGroup align="left">
				<h3><h:link outcome="home.html" value="TravelDream" /></h3>
			</p:toolbarGroup>
			<p:toolbarGroup align="right">

				<h:form>

					<p:commandButton action="#{logoutBean.logout}" value="Logout" />

				</h:form>
				<p:spacer width="10"></p:spacer>

				<p:spacer width="10"></p:spacer>
			</p:toolbarGroup>
		</p:toolbar>
	</p:layoutUnit>



	<p:growl id="growl" showDetail="true" />
	<h2>Modify your Package!</h2>
	<table>
	<tr>
		<td><p:commandButton id="saveButton" value="Save"
		action="#{savedPackageBean.updateSavedPackage()}"/>
		</td>
		<td><p:commandButton id="confButton" value="Confirm"
		action="#{savedPackageBean.confirmSavedPackage()}"/>
		</td>
	</tr>
	</table>
	<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /> 
	<h:form>
		<table>
			<tr>
				<td><h:outputText value="You are leaving from: " /> <p:inplace
						id="depLoc" editor="true" emptyLabel="-----">
						<p:inputText value="#{savedPackageBean.tempSavedPackage.depLocation}"
							label="text" />
					</p:inplace> <p:commandButton value="Apply"
						action="#{savedPackageBean.modifyDepLoc()}">
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						</p:commandButton>
						</td>
			</tr>

			<tr>
				<td><h:outputText value="You are going to: " /> <p:inplace
						id="arrLoc" editor="true" emptyLabel="-----">
						<p:inputText value="#{savedPackageBean.tempSavedPackage.arrLocation}"
							label="text" />
					</p:inplace> <p:commandButton value="Apply"
						action="#{savedPackageBean.modifyArrLoc()}" >
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						</p:commandButton>
						</td>
			</tr>
			<tr>
				<td><h:outputText value="Departure Date: " /> <p:inplace
						id="date" editor="true" emptyLabel="-----">
						<p:calendar value="#{savedPackageBean.tempSavedPackage.depDate}"
							pattern="MM/dd/yyyy" label="text" />
					</p:inplace> <p:commandButton value="Apply"
						action="#{savedPackageBean.modifyDate()}" >
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						</p:commandButton>
						</td>
			</tr>
			<tr>
				<td><h:outputText value="Return Date: " /> <p:inplace
						id="dateR" editor="true" emptyLabel="-----">
						<p:calendar value="#{savedPackageBean.tempSavedPackage.retDate}"
							pattern="MM/dd/yyyy" label="text" />
					</p:inplace> <p:commandButton value="Apply"
						action="#{savedPackageBean.modifyRetDate()}" >
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						</p:commandButton>
						</td>
				<td><h:outputText value="Total People: " /> <p:inplace
						id="tot" emptyLabel="-----">
						<h:selectOneMenu value="#{savedPackageBean.savedPackage.creatorPeople}" >
				            <f:selectItem itemLabel="1" itemValue="1" />  
				            <f:selectItem itemLabel="2" itemValue="2" />  
				            <f:selectItem itemLabel="3" itemValue="3" />
				            <f:selectItem itemLabel="4" itemValue="4" />  
				            <f:selectItem itemLabel="5" itemValue="5" />  
				            <f:selectItem itemLabel="6" itemValue="6" />
				         </h:selectOneMenu>
				         </p:inplace>			        
						 <p:commandButton value="Apply"
						action="#{savedPackageBean.modifyTotPeople()}" >
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						</p:commandButton>
						</td>
			</tr>
		</table>
	</h:form>



	<p:panel id="pnl" header="Outgoing Flight" toggleable="true"
		toggleSpeed="500" closeSpeed="500">

		<p:dataTable id="selectedFlightTable" var="FlightDTO"
			value="#{savedPackageBean.selectedFlight}"
			rendered="#{savedPackageBean.outFlight}">

			<p:column headerText="Departure Location" style="width:24%">
				<h:outputText value="#{FlightDTO.depLocation}" />
			</p:column>

			<p:column headerText="Arrival Location" style="width:24%">
				<h:outputText value="#{FlightDTO.arrLocation}" />
			</p:column>

			<p:column headerText="Date" style="width:24%">
				<h:outputText value="#{FlightDTO.date_Time}" />
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="selectButtonF" update=":formF:displayF"
					oncomplete="PF('flightDialog').show()" icon="ui-icon-search"
					title="View">
					<f:setPropertyActionListener value="#{FlightDTO}"
						target="#{searchBean.selectedFlight}" />
					<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="removeButtonF" title="Eliminate"
					action="#{savedPackageBean.removeOutFlight()}"
					icon="ui-icon-circle-close">
					<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>
		</p:dataTable>

		<p:commandButton id="RetsearchButton" value="Search"
			action="#{savedPackageBean.searchOutFlight()}">
			<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
						
		</p:commandButton>

		<h:form id="formF">

			<p:growl id="msgF" showDetail="true" />

			<p:dataTable id="filteredList" var="FlightDTO"
				value="#{savedPackageBean.filteredList}"
				rendered="#{savedPackageBean.renderFlight}">

				<p:column headerText="Departure Location" style="width:24%">
					<h:outputText value="#{FlightDTO.depLocation}" />
				</p:column>

				<p:column headerText="Arrival Location" style="width:24%">
					<h:outputText value="#{FlightDTO.arrLocation}" />
				</p:column>

				<p:column headerText="Date" style="width:24%">
					<h:outputText value="#{FlightDTO.date_Time}" />
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonF" update=":formF:displayF"
						oncomplete="PF('flightDialog').show()" icon="ui-icon-search"
						title="View">
						<f:setPropertyActionListener value="#{FlightDTO}"
							target="#{searchBean.selectedFlight}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />						
					</p:commandButton>
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonF2" value="Save"
						action="#{savedPackageBean.changeOutFlight()}">
						<f:setPropertyActionListener value="#{FlightDTO}"
							target="#{savedPackageBean.selectedFlight}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />							
					</p:commandButton>
				</p:column>

			</p:dataTable>

			<p:dialog header="Flight Detail" widgetVar="flightDialog"
				resizable="false" id="FDlg" showEffect="fade" hideEffect="explode"
				modal="true">

				<h:panelGrid id="displayF" columns="2" cellpadding="4"
					style="margin:0 auto;">

					<f:facet name="header">  
			                FLIGHT:  
			            </f:facet>

					<h:outputText value="Departure Airport" />
					<h:outputText value="#{searchBean.selectedFlight.depAirport}"
						style="font-weight:bold" />

					<h:outputText value="Arrival Airport:" />
					<h:outputText value="#{searchBean.selectedFlight.arrAirport}"
						style="font-weight:bold" />


					<h:outputText value="Description:" />
					<h:outputText value="#{searchBean.selectedFlight.description}"
						style="font-weight:bold" />

					<h:outputText value="Flag:" />
					<h:outputText value="#{searchBean.selectedFlight.flag}"
						style="font-weight:bold" />

					<h:outputText value="Price:" />
					<h:outputText value="#{searchBean.selectedFlight.price} €"
						style="font-weight:bold" />

					<h:outputText value="Capacity:" />
					<h:outputText value="#{searchBean.selectedFlight.capacity}"
						style="font-weight:bold" />

				</h:panelGrid>

			</p:dialog>

		</h:form>

	</p:panel>

	<p:panel id="pnl2" header="Return Flight" toggleable="true"
		toggleSpeed="500" closeSpeed="500" widgetVar="panel2">

		<p:dataTable id="selectedRetFlightTable" var="FlightDTO"
			value="#{savedPackageBean.selectedRetFlight}"
			rendered="#{savedPackageBean.retFlight}">

			<p:column headerText="Departure Location" style="width:24%">
				<h:outputText value="#{FlightDTO.depLocation}" />
			</p:column>

			<p:column headerText="Arrival Location" style="width:24%">
				<h:outputText value="#{FlightDTO.arrLocation}" />
			</p:column>

			<p:column headerText="Date" style="width:24%">
				<h:outputText value="#{FlightDTO.date_Time}" />
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="selectButtonF" update=":formF:displayF"
					oncomplete="PF('flightDialog').show()" icon="ui-icon-search"
					title="View">
					<f:setPropertyActionListener value="#{FlightDTO}"
						target="#{searchBean.selectedFlight}" />
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="removeButtonF" title="Eliminate"
					icon="ui-icon-circle-close"
					action="#{savedPackageBean.removeRetFlight()}">
					<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>
		</p:dataTable>

		<p:commandButton id="searchButton" value="Search"
			action="#{savedPackageBean.searchRetFlight()}">
			<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
		</p:commandButton>

		<h:form id="formRetF">

			<p:growl id="msgF" showDetail="true" />

			<p:dataTable id="filteredRetList" var="FlightDTO"
				value="#{savedPackageBean.filteredRetList}"
				rendered="#{savedPackageBean.renderRetFlight}">

				<p:column headerText="Departure Location" style="width:24%">
					<h:outputText value="#{FlightDTO.depLocation}" />
				</p:column>

				<p:column headerText="Arrival Location" style="width:24%">
					<h:outputText value="#{FlightDTO.arrLocation}" />
				</p:column>

				<p:column headerText="Date" style="width:24%">
					<h:outputText value="#{FlightDTO.date_Time}" />
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonRetF"
						update=":formRetF:displayRetF"
						oncomplete="PF('retflightDialog').show()" icon="ui-icon-search"
						title="View">
						<f:setPropertyActionListener value="#{FlightDTO}"
							target="#{searchBean.selectedFlight}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonRetF2" value="Save"
						action="#{savedPackageBean.changeRetFlight()}">
						<f:setPropertyActionListener value="#{FlightDTO}"
							target="#{savedPackageBean.selectedRetFlight}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

			</p:dataTable>

			<p:dialog header="Flight Detail" widgetVar="retflightDialog"
				resizable="false" id="FDlg" showEffect="fade" hideEffect="explode"
				modal="true">

				<h:panelGrid id="displayRetF" columns="2" cellpadding="4"
					style="margin:0 auto;">

					<f:facet name="header">  
			                FLIGHT:  
			            </f:facet>

					<h:outputText value="Departure Airport" />
					<h:outputText value="#{searchBean.selectedFlight.depAirport}"
						style="font-weight:bold" />

					<h:outputText value="Arrival Airport:" />
					<h:outputText value="#{searchBean.selectedFlight.arrAirport}"
						style="font-weight:bold" />


					<h:outputText value="Description:" />
					<h:outputText value="#{searchBean.selectedFlight.description}"
						style="font-weight:bold" />

					<h:outputText value="Flag:" />
					<h:outputText value="#{searchBean.selectedFlight.flag}"
						style="font-weight:bold" />

					<h:outputText value="Price:" />
					<h:outputText value="#{searchBean.selectedFlight.price}"
						style="font-weight:bold" />

					<h:outputText value="Capacity:" />
					<h:outputText value="#{searchBean.selectedFlight.capacity}"
						style="font-weight:bold" />

				</h:panelGrid>

			</p:dialog>

		</h:form>


	</p:panel>

	<p:panel id="pnl3" header="Hotel" toggleable="true" toggleSpeed="500"
		closeSpeed="500" widgetVar="panel3" >
		<p:dataTable id="selectedHotelTable" var="HotelDTO"
			value="#{savedPackageBean.selectedHotel}" rendered="#{savedPackageBean.hotel}">

			<p:column headerText="Name" style="width:24%">
				<h:outputText value="#{HotelDTO.name}" />
			</p:column>

			<p:column headerText="Category" style="width:24%">
				<h:outputText value="#{HotelDTO.category}" />
			</p:column>

			<p:column headerText="Price per Night" style="width:24%">
				<h:outputText value="#{HotelDTO.price_Night}" />
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="selectButtonH" update=":formH:displayH"
					oncomplete="PF('hotelDialog').show()" icon="ui-icon-search"
					title="View">
					<f:setPropertyActionListener value="#{HotelDTO}"
						target="#{searchBean.selectedHotel}" />
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="removeButtonH" title="Eliminate"
					icon="ui-icon-circle-close" action="#{savedPackageBean.removeHotel()}">
					<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>
		</p:dataTable>

		<p:commandButton id="HotSearchButton" value="Search"
			action="#{savedPackageBean.searchHotel()}">
			<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
		</p:commandButton>

		<h:form id="formH">

			<p:growl id="msgH" showDetail="true" />

			<p:dataTable id="filteredHotList" var="HotelDTO"
				value="#{savedPackageBean.filteredHotList}"
				rendered="#{savedPackageBean.renderHotel}">

				<p:column headerText="Name" style="width:24%">
					<h:outputText value="#{HotelDTO.name}" />
				</p:column>

				<p:column headerText="Category" style="width:24%">
					<h:outputText value="#{HotelDTO.category}" />
				</p:column>

				<p:column headerText="Price per Night" style="width:24%">
					<h:outputText value="#{HotelDTO.price_Night}" />
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonH" update=":formH:displayH"
						oncomplete="PF('hotelDialog').show()" icon="ui-icon-search"
						title="View">
						<f:setPropertyActionListener value="#{HotelDTO}"
							target="#{searchBean.selectedHotel}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonH2" value="Save"
						action="#{savedPackageBean.changeHotel()}">
						<f:setPropertyActionListener value="#{HotelDTO}"
							target="#{savedPackageBean.selectedHotel}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

			</p:dataTable>

			<p:dialog header="Hotel Detail" widgetVar="hotelDialog"
				resizable="false" id="FDlg" showEffect="fade" hideEffect="explode"
				modal="true">

				<h:panelGrid id="displayH" columns="2" cellpadding="4"
					style="margin:0 auto;">

					<f:facet name="header">
						<h:outputText value="#{searchBean.selectedHotel.name}"
							style="font-weight:bold" />
					</f:facet>

					<h:outputText value="Address:" />
					<h:outputText value="#{searchBean.selectedHotel.address}"
						style="font-weight:bold" />

					<h:outputText value="Cap:" />
					<h:outputText value="#{searchBean.selectedHotel.cap}"
						style="font-weight:bold" />


					<h:outputText value="Description:" />
					<h:outputText value="#{searchBean.selectedHotel.description}"
						style="font-weight:bold" />

					<h:outputText value="Web-site:" />
					<h:outputText value="#{searchBean.selectedHotel.website}"
						style="font-weight:bold" />

					<h:outputText value="Category:" />
					<h:outputText value="#{searchBean.selectedHotel.category}"
						style="font-weight:bold" />

				</h:panelGrid>

			</p:dialog>

		</h:form>

	</p:panel>

	<p:panel id="pnl4" header="Excursions" toggleable="true"
		toggleSpeed="500" closeSpeed="500" widgetVar="panel4">
		<p:dataTable id="selectedExcursionsTable" var="ExcursionDTO"
			value="#{savedPackageBean.selectedExcursionsList}"
			rendered="#{!savedPackageBean.selectedExcursionsList.isEmpty()}">

			<p:column headerText="Name" style="width:24%">
				<h:outputText value="#{ExcursionDTO.name}" />
			</p:column>

			<p:column headerText="Date" style="width:24%">
				<h:outputText value="#{ExcursionDTO.date}" />
			</p:column>

			<p:column headerText="Price" style="width:24%">
				<h:outputText value="#{ExcursionDTO.price}" />
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="selectButtonE" update=":formE:displayE"
					oncomplete="PF('excursionDialog').show()" icon="ui-icon-search"
					title="View">
					<f:setPropertyActionListener value="#{ExcursionDTO}"
						target="#{searchBean.selectedExcursion}" />
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>

			<p:column style="width:4%">
				<p:commandButton id="removeButtonE" title="Eliminate"
					icon="ui-icon-circle-close"
					action="#{savedPackageBean.removeExcursion()}">
					<f:setPropertyActionListener value="#{ExcursionDTO}"
						target="#{savedPackageBean.selectedExcursion}" />
						<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
				</p:commandButton>
			</p:column>
		</p:dataTable>

		<p:commandButton id="ExcSearchButton" value="Search"
			action="#{savedPackageBean.searchExcursion()}">
			<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
		</p:commandButton>

		<h:form id="formE">

			<p:growl id="msgE" showDetail="true" />

			<p:dataTable id="filteredExcList" var="ExcursionDTO"
				value="#{savedPackageBean.filteredExcList}"
				rendered="#{savedPackageBean.renderExcursion}">

				<p:column headerText="Name" style="width:24%">
					<h:outputText value="#{ExcursionDTO.name}" />
				</p:column>

				<p:column headerText="Date" style="width:24%">
					<h:outputText value="#{ExcursionDTO.date}" />
				</p:column>

				<p:column headerText="Price" style="width:24%">
					<h:outputText value="#{ExcursionDTO.price}" />
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonE" update=":formE:displayE"
						oncomplete="PF('excursionDialog').show()" icon="ui-icon-search"
						title="View">
						<f:setPropertyActionListener value="#{ExcursionDTO}"
							target="#{searchBean.selectedExcursion}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButtonE2" value="Save"
						action="#{savedPackageBean.addExcursion()}">
						<f:setPropertyActionListener value="#{ExcursionDTO}"
							target="#{savedPackageBean.selectedExcursion}" />
							<f:setPropertyActionListener target="#{savedPackageBean.creationPage}" value="true" />
					</p:commandButton>
				</p:column>

			</p:dataTable>

			<p:dialog header="Excursion Detail" widgetVar="excursionDialog"
				resizable="false" id="EDlg" showEffect="fade" hideEffect="explode"
				modal="true">

				<h:panelGrid id="displayE" columns="2" cellpadding="4"
					style="margin:0 auto;">

					<f:facet name="header">
						<h:outputText value="#{searchBean.selectedExcursion.name}"
							style="font-weight:bold" />
					</f:facet>

					<h:outputText value="Description:" />
					<h:outputText value="#{searchBean.selectedExcursion.description}"
						style="font-weight:bold" />

					<h:outputText value="Type:" />
					<h:outputText value="#{searchBean.selectedExcursion.type}"
						style="font-weight:bold" />


					<h:outputText value="Price:" />
					<h:outputText value="#{searchBean.selectedExcursion.price}"
						style="font-weight:bold" />

					<h:outputText value="Web-site:" />
					<h:outputText value="#{searchBean.selectedExcursion.website}"
						style="font-weight:bold" />

				</h:panelGrid>

			</p:dialog>

		</h:form>

	</p:panel>



</body>
</html>
